package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysVideo;
import com.ruoyi.system.service.ISysVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 视频管理Controller
 *
 * @author ruoyi
 * @date 2021-06-01
 */
@RestController
@RequestMapping("/system/video")
public class SysVideoController extends BaseController
{
    @Autowired
    private ISysVideoService sysVideoService;

    /**
     * 查询视频管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:video:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysVideo sysVideo)
    {
        startPage();
        List<SysVideo> list = sysVideoService.selectSysVideoList(sysVideo);
        return getDataTable(list);
    }

    /**
     * 导出视频管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:video:export')")
    @Log(title = "视频管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SysVideo sysVideo)
    {
        List<SysVideo> list = sysVideoService.selectSysVideoList(sysVideo);
        ExcelUtil<SysVideo> util = new ExcelUtil<SysVideo>(SysVideo.class);
        return util.exportExcel(list, "视频管理数据");
    }

    /**
     * 获取视频管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:video:query')")
    @GetMapping(value = "/{vid}")
    public AjaxResult getInfo(@PathVariable("vid") Integer vid)
    {
        return AjaxResult.success(sysVideoService.selectSysVideoById(vid));
    }

    /**
     * 新增视频管理
     */
    @PreAuthorize("@ss.hasPermi('system:video:add')")
    @Log(title = "视频管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysVideo sysVideo)
    {
        return toAjax(sysVideoService.insertSysVideo(sysVideo));
    }

    /**
     * 修改视频管理
     */
    @PreAuthorize("@ss.hasPermi('system:video:edit')")
    @Log(title = "视频管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysVideo sysVideo)
    {
        return toAjax(sysVideoService.updateSysVideo(sysVideo));
    }

    /**
     * 删除视频管理
     */
    @PreAuthorize("@ss.hasPermi('system:video:remove')")
    @Log(title = "视频管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{vids}")
    public AjaxResult remove(@PathVariable Integer[] vids)
    {
        return toAjax(sysVideoService.deleteSysVideoByIds(vids));
    }
}
